Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@kotori-bot/logger
Advanced tools
Here are a simple logger,used mainly in Node.js environment,can record quickly log of application at runtime.
new Logger(options: LoggerOptions)
interface LoggerOptions {
level: LoggerLevel;
filter?: (data: LoggerData) => boolean;;
label: string[];
transports: Transport | Transport[];
}
// ./src/example/example1.ts
import Logger, { ConsoleTransport, LoggerLevel } from '@kotori-bot/logger';
const logger = new Logger({
level: LoggerLevel.TRACE,
label: [],
transports: new ConsoleTransport()
});
logger.info(`base type:`, 'string', 233, null, undefined, true, false, 2.7182818284);
logger.fatal(`normal object (json):`, { value: 1, content: 'content', extends: { value: 2 } }, [
1,
null,
{ value: false },
'string'
]);
const obj: any = {};
obj.value = obj;
logger.error(`loop object:`, obj);
logger.warn(`javascript special type:`, Symbol(233), BigInt('1234567891011121314151617181920'));
logger.debug(`javascript object:`, Math, globalThis);
logger.trace(`javascript constructor:`, Object, Function, String, Number, Boolean, Set, Map, Symbol, Error, Date);
logger.label('label1').info(
`javascript object instance`,
new Map([
[1, 3],
[2, 3],
[3, 4],
[4, 5]
]),
new Set([1, 3, 3, 4, 5, 6, 7, 7, 8]),
new Proxy({}, {}),
new Error('a error'),
new Date()
);
function a() {}
class A {}
const b = () => {};
logger
.label('label father')
.label('label child')
.warn(`function and class`, a, A, b, () => {}, new A());
Reference source of pre-tansports,here are a simple example:
import { LoggerData, Transport } from '@kotori-bot/logger';
interface MyTransportConfig {
/* ... */
}
export class MyTransport extends Transport<MyTransportConfig> {
handle(data: LoggerData) {
/* here are some log handle logic... */
}
escaper = (...args: unknown): string => {
/* if need,you can custom escaper */
/* finally return a string as key msg of LoggerData */
/* it's optional */
};
}
export default MyTransport;
FAQs
Logger For Kotori
The npm package @kotori-bot/logger receives a total of 5 weekly downloads. As such, @kotori-bot/logger popularity was classified as not popular.
We found that @kotori-bot/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.